package cn.itcast.tanhua.mytanhuaserver.controller;

import cn.itcast.tanhua.mytanhuaserver.service.AddBlacklistService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * 黑名单
 * @author 陈英航
 * @since 2021/12/6 15:51
 */
@RequestMapping("blackLike")
@RestController
@Slf4j
public class AddBlacklistController {

    @Autowired
    private AddBlacklistService addBlacklistService;

    /**
     * 添加黑名单
     * @param userId
     * @return
     */
    @PostMapping("blacklist/{uid}")
    public ResponseEntity<Void> delBlacklist(@PathVariable("uid") Long userId) {
        try {
            Boolean result = this.addBlacklistService.addBlacklist(userId);

            if (result){
                return ResponseEntity.ok(null);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    }

}
